# -*-coding:utf-8 -*-
from django.shortcuts import render

from django.http import HttpRequest

from message.models import Message

import locale

# Create your views here.

def get_form(request):
    if request.method == 'GET':
        messages = Message.objects.all()
        message = messages[0]
        name = message.name
        email = message.email
        address = message.address
        message = message.message
    elif request.method == 'POST':
        new_msg = Message()
        new_msg.name = request.POST.get('name','')
        new_msg.email = request.POST.get('email','')
        new_msg.address = request.POST.get('address','')
        new_msg.message = request.POST.get('message','')
        new_msg.object_id = 'hello2'
        new_msg.save()
    return render(request,'message_form.html',locals())